const userList = []

class User {
  constructor(name) {
    this.name_ = name
  }
}

const proxy = new Proxy(User, {
  construct() {
    const newUser = Reflect.construct(...arguments)
    userList.push(newUser)
    return newUser
  }
})

new proxy('holo')
new proxy('pika')
new proxy('xiGua')
// console.log(userList)

console.log('-------------------------------------------------')


const userList2 = []

function emit(newValue) {
  console.log(newValue)
}

const proxy2 = new Proxy(userList2, {
  set() {
    console.log(arguments)
    const result = Reflect.set(...arguments)
    if (result) {
      emit(result)
    }
    return result
  }
})

proxy2.push('holo')


